#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include "FoICMPstruct.h"


/*
DWORD WINAPI Banner(LPVOID Parm);
DWORD ThreadId;
HANDLE ThreadHandle;
int Parm = 0;
*/
int main(int argc, char * argv[])
{
/*
    ThreadHandle = CreateThread(NULL, 0, Banner, &Parm, 0, &ThreadId);
    if (ThreadHandle != NULL )
 *
    CloseHandle(ThreadHandle);
*/
    InitLog("log.txt", 15);

    if (argc < 2 )
    {
        printf("Wrong amount of parameters: %d\n foicmp r|s file\n", argc - 1);
        CloseLog();
        return 1;
    }

    if (*argv[1] == 'r' || *argv[1] == 'R')
    {
        puts("Configuring WinPCAP: ");
        if ( receiverConnectPcap() != 0 )
        {
            puts("Failed\n");
            puts("Configuring WinSock2: ");
            if ( receiverConnectSock() != 0 )
            {
                puts("Failed\n");
                CloseLog();
                return 1;
            }
        }
    }
    else
    {
        if ((*argv[1] == 's' || *argv[1] == 'S') && argc == 4)
        {
            senderConnect(argv[3], argv[2]);
        }
        else
        {
            printf("Wrong parameters\nfoicmp r|s [address] [files]\n");
            CloseLog();
            return 1;
        }
    }

    CloseLog();

    return 0;
}
/*
DWORD WINAPI Banner(LPVOID Parm)
{
    while(TRUE)
    {
        printf("Banner parm: %d\n", (int)Parm );
        Sleep(3000);
    }
}
*/
